package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * @EnumName ColumnExceptionEnum
 * @Description TODO
 * @Author Mr.zheng
 * @Date 2018/6/7 11:48
 * @Version 1.0
 */
public enum ColumnExceptionEnum implements CustomExceptionCode {
    COLUMN_IS_EXIST(300, "该分类名称或别名已存在", 900),
    COLUMN_NOT_EXIST(301, "该分类不存在", 900),
    COLUMN_SAVE_ERROE(302, "添加文章分类失败", 900),
    COLUMN_DELETE_ERROE(303,"删除文章分类失败",900),
    COLUMN_NOT_DELETE_BY_PARENT(304,"该分类为父类无法删除，请先删除其子类",900),
    COLUMN_NOT_DELETE_BY_ARTICLE(305,"该分类下有文章无法删除，请先删除文章",900),
    COLUMN_UPDATE_ERROE(306,"修改文章分类失败",900),
    COLUMN_NOT_VOID(307,"文章分类信息不能为空",900),
    COLUMN_NOT_NAME(308,"文章分类名称不能为空",900),
    COLUMN_NOT_SITEID(309,"站点ID为空",900),
    COLUMN_SORT_NUM_ERROE(310,"文章分类排序失败",900),
    COLUMN_AS_CHANNEL_NOT_EXIST(311,"请将频道名称与分类名称匹配",900),
    COLUMN_AS_CREATE_TEMPLTE_NOT_EXIST(312,"一键生成静态文件失败!",900),
    COLUMN_SEARCH_TAGS_NOT_EXIST(313,"查询分类数据失败!",900),
    COLUMN_FREEMARKER_ERRO(314, "分类列表模板解析失敗", 900),
    COLUMN_TEMPID_NOT_NULL(315, "请选择分类列表模板哦", 900),
    COLUMN_TEMPLTEID_NOT_NULL(315, "请选择文章详情模板哦", 900),
    COLUMN_SAVE_ERROR_BY_ARTICLE_EXIST(317, "当前分类下有正在使用的文章或回收站中有未删除的文章，不能添加子分类！", 900),
    ;
    private Integer code;
    private String msg;
    private Integer httpCode;

    ColumnExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }

    public static ColumnExceptionEnum getEnumByCode(Integer code){
        for(ColumnExceptionEnum columnExceptionEnum : ColumnExceptionEnum.values()){
            if(code.equals(columnExceptionEnum.getCode())){
                return columnExceptionEnum;
            }
        }
        return null;
    }
}
